package nels4561;

public class NeuralNetwork {
	
	private Neuron[] inputLayer;
	private Neuron[] hiddenLayer;
	private Neuron[] outputLayer;
	
	public NeuralNetwork(int inputSize, int hiddenSize, int outputSize)
	{
		inputLayer = new Neuron[inputSize];
		hiddenLayer = new Neuron[hiddenSize];
		outputLayer = new Neuron[outputSize];
		
		for (int i = 0; i < inputSize; i++)
		{
			inputLayer[i] = new Neuron();
		}
		
		for (int i = 0; i < hiddenSize; i++)
		{
			hiddenLayer[i] = new Neuron();
		}
		
		for (int i = 0; i < outputSize; i++)
		{
			outputLayer[i] = new Neuron();
		}
		
		setSynapses();
	}
	
	public void setSynapses()
	{
		for (int i = 0; i < inputLayer.length; i++)
		{
			for (int j = 0; j < hiddenLayer.length; j++)
			{
				Synapse s = new Synapse(inputLayer[i], hiddenLayer[j]);
				
				hiddenLayer[j].addInputSynapse(s);
			}
		}
		
		for (int i = 0; i < hiddenLayer.length; i++)
		{
			for (int j = 0; j < outputLayer.length; j++)
			{
				Synapse s = new Synapse(hiddenLayer[i], outputLayer[j]);
				
				outputLayer[j].addInputSynapse(s);
			}
		}
	}
	
	public Neuron[] processNetwork()
	{
		for (int i = 0; i < inputLayer.length; i++)
		{
			inputLayer[i].setOutput();
		}
		
		for (int i = 0; i < hiddenLayer.length; i++)
		{
			hiddenLayer[i].setOutput();
		}
		
		for (int i = 0; i < outputLayer.length; i++)
		{
			outputLayer[i].setOutput();
		}
		
		return outputLayer;
	}

}
